var drgs;
var drgSortArray=new Array();
var roleCode;
var depCode;
var dataCopy=new Array();
//新增左侧echart图的id值
var myEchartId = 'myEchartId';
$(function(){
	showCondition(true, 0, 0, 1,[]);//加载查询条件
	tabId=$("#tabContent > .tab-pane.active").attr("id");//获取当前选中tab页的tabId
	var param = drgUI.setAjaxData(tabId);//获取当前页面 初始参数
	$("#navTabs").find("li").each(function(i){
		$(this).on("click", function () {
			scrollTo(0,0);
			tabId=$("#tabContent > .tab-pane.active").attr("id");
         });
	});
	
	//修改tab标签页href
	$("#"+tabId+" ul > li a").each(function(){
		$(this).attr("href",$(this).attr("href")+tabId);//赋值
	});
	
	//修改tab内容页ID
	$("#"+tabId+" .tab-content div[role='tabpanel']").each(function(){
		$(this).attr("id",$(this).attr("id")+tabId);//赋值
	});
	
	
	
	roleCode = $('#roles').text();
	depCode = $('#deps_id').val();

	myEchartId = 'myEchartId'+(param.depCode? param.depCode :'');
	$('#'+tabId+' #compareDiv').removeAttr('style');
	//这里为图表容器赋予了id值，如果没有此id值则从科室指标象限分析--二级科室分析页面，点击“病组结构分析”按钮跳转进来的页面
	//与从左侧菜单栏点击“病组结构分析”菜单进来的页面，这两个页面只有一个有左侧的柱图，另外一个左侧为空
	$('#'+tabId+' #compareDiv').html('<table><tr><td width="40%"><div id="'+myEchartId+'" class="echartscq" style="width:450px; height:350px;"></div></td><td width="60%" valign="top">'
		 	+'<table class="table table-bordered table-hover" '
		 	+'style="text-align: center;transition:all .2s;vertical-align: ;">'
		 	+'<thead><tr>'
		 	+'<th width="210"></th>'
		 	+'<th width="150">总费用(万元)</th>'
		 	+'<th width="140">次均费用(元)</th>'
		 	+'<th width="140">次均费用变化</th>'//与去年均值差</td>'
		 	+'<th width="150">次均费用合理变化率</th>'//与全市均值差</td>'
		 	+'</tr>'
		 	+'</thead>'
		 	+'<tbody id="table1"></tbody>'
		 	+'</table> <div class="zhujie">'
		 	+'<div>注:</div>'
		 	+'<div>本期或同期理论值是根据 <label id="stdyear_1"></label>年 DRG病组次均费用标杆值，结合本期或同期实际病组结构计算得出的。</div>'
		 	+'<div>本期理论次均费用与去年同期相比， <label id="avgFee_1"></label>元</div>'
		 	+'<div>实际值是根据本院出院病例实际出院总费用计算得出的。</div>'
		 	+'<div>本期实际次均费用与去年同期相比， <label id="avgFee_2"></label>元</div>'
		 	+'<div>本期次均费用变化<label id="avgFeeRatio_1"></label>, <label id="avgFeeRatio_2"></label></div></div>'
		 	+'</td></tr></table>'
		 	);
	if(roleCode=='科室' || '科室绩效'==roleCode){//临床科主任角色
		if(depCode==null||depCode=="")
		{//如果角色还未授权科室 无法查看数据
			$('#'+tabId+' #warninginfo').css('display','block');
			$('#'+tabId+' .container').css('display','none');
			return;
		}
		//如果是  科室指标象限分析--二级科室分析页面，点击“病组结构分析”按钮跳转进来的，则隐藏所有科室组，科室，院区的下拉框，并加载上级页面传递过来的科室信息
		if(param.patientGroupAnalysisPage == 'yibao' || param.patientGroupAnalysisPage == 'yizheng'){
			$('#'+tabId+' .con-row').css('display','none');
			//隐藏所有科室组，科室，院区的下拉框
			$('#'+tabId+' #depGroupList').parent().css('display','none');	
			$('#'+tabId+' #depList').parent().css('display','none');
			$('#'+tabId+' #wardList').parent().css('display','none');
			param.deps = depCode;
			//加载上级页面传递过来的科室信息
			$.getJSON(contextPath+'/DrgsIndexCal/findAllDepByHospCode.dhc',param,function(data){
				var data=data.data;
				var depCodeFirst = '';
				if(data.length>0){
					depCodeFirst=param.depCode;
				}
				var optStr="";
				for (var i = 0; i < data.length; i++) {
					optStr = optStr + '<option value="' + data[i].DEPCODE +'" ';
					data[i].DEPCODE == param.depCode ? optStr = optStr +' selected="selected" ' : '';				
					optStr = optStr + '>' + data[i].DEPNAME + '</option>';
				}
				$("#" + tabId + " #depList").append(optStr);
				$("#" + tabId + " #depList").val(depCodeFirst);
				loadDrgAnalysisTable('null', depCodeFirst,'null');//页面刷新自动加载默认的第一个科室
			})
		}else{//如果是其他路径进来的则正常显示
			$('#'+tabId+' .con-row').css('display','none');
			$('#'+tabId+' #depList').parent().css('display','block');
			$('#'+tabId+' #wardList').parent().css('display','none');
			$('#'+tabId+' #depList').html('');
			param.deps = depCode;
			var depCodeFirst="";
			$('#'+tabId+' #depGroupList').parent().css('display','none');
			$.getJSON(contextPath+'/DrgsIndexCal/findAllDepByHospCode.dhc',param,function(data){
				var data=data.data;
				if(data.length>0){
					depCodeFirst=data[0].DEPCODE;
				}
				var optStr="";
				for (var i = 0; i < data.length; i++) {
					optStr = optStr + '<option value="' + data[i].DEPCODE
					+ '">' + data[i].DEPNAME + '</option>';
				}
				$("#" + tabId + " #depList").append(optStr);
				$("#" + tabId + " #depList").val(depCodeFirst);
				$("#" + tabId + " #depList").trigger("onchange");//手动触发change事件
				loadDrgAnalysisTable('null', depCodeFirst,'null');//页面刷新自动加载默认的第一个科室
			})
		}
	}
	else
	{//当是医政/医保角色时
		$('#'+tabId+' .con-row').css('display','none');
		//如果是  科室指标象限分析--二级科室分析页面，点击“病组结构分析”按钮跳转进来的，则隐藏所有科室组，科室，院区的下拉框，并加载上级页面传递过来的科室信息
		if(param.patientGroupAnalysisPage == 'yibao' ){
			//隐藏所有科室组，科室，院区的下拉框
			$('#'+tabId+' #depGroupList').parent().css('display','none');	
			$('#'+tabId+' #depList').parent().css('display','none');
			$('#'+tabId+' #wardList').parent().css('display','none');
			//加载上级页面传递过来的科室信息
			$.getJSON(contextPath+'/DrgsIndexCal/findAllDepByHospCode.dhc',param,function(data){
				var data=data.data;
				var depCodeFirst = param.depCode;
				var optStr="";
				for (var i = 0; i < data.length; i++) {
					optStr = optStr + '<option value="' + data[i].DEPCODE +'" ';
					data[i].DEPCODE == depCodeFirst ? optStr = optStr +' selected="selected" ' : '';				
					optStr = optStr + '>' + data[i].DEPNAME + '</option>';
				}
				$("#" + tabId + " #depList").append(optStr);
				$("#" + tabId + " #depList").val(depCodeFirst);
				loadDrgAnalysisTable('null', depCodeFirst,'null');//页面刷新自动加载默认的第一个科室
			})
		}else{//如果是其他路径进来的则正常显示
			if(commonLayerConfig.length>=4)
			{
				if(commonLayerConfig[0]=="1"){//科室组层次 
					//显示科室组区域
					$('#'+tabId+' #depGroupList').parent().css('display','block');
					$('#'+tabId+' #depList').parent().css('display','none');
					$('#'+tabId+' #wardList').parent().css('display','none');
					
					//加载全院的科室组
					$.getJSON(contextPath+'/DrgsIndexCal/getDepGroupByCode.dhc',{'hospCode':param.hospCode},
						function(depGroups){
						var data = depGroups.data;
						var optStr = '<option value="hosp" selected="selected">' + "全院"+ '</option>';
						for (var i = 0; i < data.length; i++) {
								optStr = optStr + '<option value="' + data[i].CODE
										+ '">' + data[i].NAME + '</option>';
						}
						$("#" + tabId + " #depGroupList").append(optStr);
					});
				}else if(commonLayerConfig[1]=="1"){//科室层次
					$('#'+tabId+' #depGroupList').parent().css('display','none');
					$('#'+tabId+' #wardList').parent().css('display','none');
					$('#'+tabId+' #depList').parent().css('display','block');
					
					$.getJSON(contextPath+'/DrgsIndexCal/findAllDepByHospCode.dhc',param,function(deps){
						var data = deps.data;
						var optStr = '<option value="" selected="selected">' + "全院"+ '</option>';
						for (var i = 0; i < data.length; i++) {
							if (i == 0) {
								optStr = optStr + '<option value="' + data[i].DEPCODE
										+ '">' + data[i].DEPNAME
										+ '</option>';
							} else {
								optStr = optStr + '<option value="' + data[i].DEPCODE
										+ '">' + data[i].DEPNAME + '</option>';
							}
						}
						$("#" + tabId + " #depList").append(optStr);
					});
				}else if(commonLayerConfig[2]=="1"){//病区层次
					$('#'+tabId+' #depGroupList').parent().css('display','none');
					$('#'+tabId+' #wardList').parent().css('display','block');
					$('#'+tabId+' #depList').parent().css('display','none');
					$.post(contextPath + '/DrgsIndexCal/getWardByCode.dhc', {
						'hospCode' : param.hospCode
					}).done(function(wards) {
						var data = wards.data;
						var optStr = '<option value="hosp" selected="selected">' + "全院"+ '</option>';
						for (var i = 0; i < data.length; i++) {
								optStr = optStr + '<option value="' + data[i].CODE
										+ '">' + data[i].NAME + '</option>';
						}
						$("#" + tabId + " #wardList").append(optStr);
					})
				}
			}
			loadDrgAnalysisTable('null', 'null','null');//页面刷新自动加载全院			
		}
	}//end else 当是医政/医保角色时
	
});

//加载表格方法
function loadDrgAnalysisTable(depGroupCode, depCode,wardCode) {
	var param = drgUI.setAjaxData(tabId);//获取当前页面 初始参数
	var timer=setTimeout(function(){
		if ($('#'+tabId+' #loading').css('display')=='block') {
			$('#'+tabId+' #loading').html('<font size="40" face="黑体"><i class="icon-exclamation-sign'
					+' icon-4x"></i><br>应该出问题了...刷新试试吧&nbsp;:)</font>')
		} 
	}, 200000);
	
	var dateFrom=param.dateFrom;
	var dateTo=param.dateTo;
	
	var showtext='';
	var isSUM=false;//是否1-n月累计
	
	var yearFrom=dateFrom.substring(0, 4);  //起始年份
	var monthFrom=dateFrom.substring(5);	//起始月份
	var yearTo=dateTo.substring(0, 4);		//结束年份
	var monthTo=dateTo.substring(5);		//结束月份
	var monitorType='';//监测类型
	
	//根据时间段判断监测类型
	//如果换成实时监测的话 可不必计算此处////////////////////
	if (yearTo-yearFrom==0) {
		if (monthTo-monthFrom==0) {
			monitorType="M";//月度监测
			showtext=parseInt(monthFrom)+'月';
		}else if (monthTo-monthFrom==2) {
			monitorType="Q";//季度监测
			if ((parseInt(monthTo)%3)==0) {
				showtext='第'+parseInt(monthTo)/3+'季度';
			} else {
                drgUI.warning('请选择正确的季度（1月-3月或4月-6月...）');
                return;
			}
		}else if (monthTo-monthFrom==5) {
			monitorType="HY";//半年监测
			if (monthTo==6) {
				showtext='上半年';
			} else {
				showtext='下半年';
			}
		}else if (monthTo-monthFrom==11) {
			monitorType="Y";//年度监测
			showtext='';
		}else if(monthFrom==1){
			monitorType='M';//1月-n月累计
			showtext='1月-'+parseInt(monthTo)+'月累计';
			//dateFrom=dateTo;
			isSUM=true;
		}else{
            drgUI.warning('该月区间没有监测~');
            return;
		}
	}
	////////////////////////////////////////////
	monitorType='M';
	var year=dateFrom.substring(0,4);
	var title=['本期'+$('.time_id').html()+'覆盖病组','同期'+getTime("year")+'覆盖病组','仅同期'+getTime("year")+'覆盖病组','仅本期'+$('.time_id').html()+'覆盖病组','次均费用本期值'+$('.time_id').html()+'<=同期值'+getTime("year")+'的病组','次均费用本期值'+$('.time_id').html()+'>同期值'+getTime("year")+'的病组'];
	var titleCode=['this','last','thisNo','lastNo','thisSmall','thisBig'];
	var param = drgUI.setAjaxData(tabId);
	param.depGroupCode = depGroupCode;
	param.depCode = depCode;
	param.wardCode = wardCode;
	param.monitorType = monitorType;
	$.post(contextPath +"/DisGroupAnalysis/drgsStructure.dhc",param).done(function(result){
		var data = result.data;
		$('#'+tabId+' #table').html('');
		//本期
		$('#'+tabId+' #table').append('<tr><td>'+title[0]+'</td><td>'+drgsCntLink(data.thisPeriod[0].DRGCNT,titleCode[0],title[0])+'</td>'
				+'<td><a href="javascript:loadCaseStructure(\'thisPeriod\')" >'+dealwithInt(data.thisPeriod[0].INCASECNT)+'</a></td>'
				+'<td>'+dealwithFloatMillion(data.thisPeriod[0].TOTALFEE)+'</td>'
				+'<td>'+dealwithFloat(data.thisPeriod[0].AVGFEE)+'</td><td>'+dealwithFloat(data.thisPeriod[0].CMI)+'</td>'
				+'<td>'+dealwithFloat(data.thisPeriod[0].TOTALWEIGHT)+'</td><td>'+overproofDrgsCntLink(data.thisPeriod[0].OVERFEECNT,titleCode[0],title[0])+'</td></tr>');
		//同期
		$('#'+tabId+' #table').append('<tr><td>'+title[1]+'</td><td>'+drgsCntLink(data.lastPeriod[0].DRGCNT,titleCode[1],title[1])+'</td>'
				+'<td><a href="javascript:loadCaseStructure(\'lastPeriod\')" >'+dealwithInt(data.lastPeriod[0].INCASECNT)+'</a></td>'
				+'<td>'+dealwithFloatMillion(data.lastPeriod[0].TOTALFEE)+'</td>'
				+'<td>'+dealwithFloat(data.lastPeriod[0].AVGFEE)+'</td><td>'+dealwithFloat(data.lastPeriod[0].CMI)+'</td>'
				+'<td>'+dealwithFloat(data.lastPeriod[0].TOTALWEIGHT)+'</td><td>'+overproofDrgsCntLink(data.lastPeriod[0].OVERFEECNT,titleCode[1],title[1])+'</td></tr>');
		//仅同期
		$('#'+tabId+' #table').append('<tr><td>'+title[2]+'</td><td>'+drgsCntLink(data.onlyLastPeriod[0].DRGCNT,titleCode[2],title[2])+'</td>'
				+'<td><a href="javascript:loadCaseStructure(\'onlyLastPeriod\')" >'+dealwithInt(data.onlyLastPeriod[0].INCASECNT)+'</a></td>'
				+'<td>'+dealwithFloatMillion(data.onlyLastPeriod[0].TOTALFEE)+'</td>'
				+'<td>'+dealwithFloat(data.onlyLastPeriod[0].AVGFEE)+'</td><td>'+dealwithFloat(data.onlyLastPeriod[0].CMI)+'</td>'
				+'<td>'+dealwithFloat(data.onlyLastPeriod[0].TOTALWEIGHT)+'</td><td>'+overproofDrgsCntLink(data.onlyLastPeriod[0].OVERFEECNT,titleCode[2],title[2])+'</td></tr>');
		//仅本期
		$('#'+tabId+' #table').append('<tr><td>'+title[3]+'</td><td>'+drgsCntLink(data.onlyThisPeriod[0].DRGCNT,titleCode[3],title[3])+'</td>'
				+'<td><a href="javascript:loadCaseStructure(\'onlyThisPeriod\')" >'+dealwithInt(data.onlyThisPeriod[0].INCASECNT)+'</a></td>'
				+'<td>'+dealwithFloatMillion(data.onlyThisPeriod[0].TOTALFEE)+'</td>'
				+'<td>'+dealwithFloat(data.onlyThisPeriod[0].AVGFEE)+'</td><td>'+dealwithFloat(data.onlyThisPeriod[0].CMI)+'</td>'
				+'<td>'+dealwithFloat(data.onlyThisPeriod[0].TOTALWEIGHT)+'</td><td>'+overproofDrgsCntLink(data.onlyThisPeriod[0].OVERFEECNT,titleCode[3],title[3])+'</td></tr>');
		//本期小
		$('#'+tabId+' #table').append('<tr><td>'+title[4]+'</td><td>'+drgsCntLink(data.thisPeriodLittle[0].DRGCNT,titleCode[4],title[4])+'</td>'
				+'<td><a href="javascript:loadCaseStructure(\'thisPeriodLittle\')" >'+dealwithInt(data.thisPeriodLittle[0].INCASECNT)+'</a></td>'
				+'<td>'+dealwithFloatMillion(data.thisPeriodLittle[0].TOTALFEE)+'</td>'
				+'<td>'+dealwithFloat(data.thisPeriodLittle[0].AVGFEE)+'</td><td>'+dealwithFloat(data.thisPeriodLittle[0].CMI)+'</td>'
				+'<td>'+dealwithFloat(data.thisPeriodLittle[0].TOTALWEIGHT)+'</td><td>'+overproofDrgsCntLink(data.thisPeriodLittle[0].OVERFEECNT,titleCode[4],title[4])+'</td></tr>');
		//本期大
		$('#'+tabId+' #table').append('<tr><td>'+title[5]+'</td><td>'+drgsCntLink(data.thisPeriodLarge[0].DRGCNT,titleCode[5],title[5])+'</td>'
				+'<td><a href="javascript:loadCaseStructure(\'thisPeriodLarge\')" >'+dealwithInt(data.thisPeriodLarge[0].INCASECNT)+'</a></td>'
				+'<td>'+dealwithFloatMillion(data.thisPeriodLarge[0].TOTALFEE)+'</td>'
				+'<td>'+dealwithFloat(data.thisPeriodLarge[0].AVGFEE)+'</td><td>'+dealwithFloat(data.thisPeriodLarge[0].CMI)+'</td>'
				+'<td>'+dealwithFloat(data.thisPeriodLarge[0].TOTALWEIGHT)+'</td><td>'+overproofDrgsCntLink(data.thisPeriodLarge[0].OVERFEECNT,titleCode[5],title[5])+'</td></tr>');
		clearTimeout(timer);
	});
	
	//与全市比较表格数据
	$.post(contextPath +"/DisGroupAnalysis/twoYearsCompare.dhc",param).done(function(result){
				var year = parseInt(dateFrom.substring(0,4));
				var data = result.data;
				dataCopy=data;
				var depType = "depGroup";
				if(depCode != null && depCode != "null"){
					depType = "dep";
				}
//				if(roleCode=='医保' || roleCode=='医政' ||roleCode == '科室'||roleCode=='超级管理员')
//				{
					var change1 = "";
					if(data.thisPeriodCity[0]["AVGFEE"]!=null&&data.lastPeriodCity[0]["AVGFEE"]!=null)
					{
						change1 = Number(data.thisPeriodCity[0]["AVGFEE"]).toFixed(2)-Number(data.lastPeriodCity[0]["AVGFEE"]).toFixed(2);
					}
					var change2 = "";
					if(data.thisPeriodThisYear[0]["AVGFEE"]!=null&&data.lastPeriodLastYear[0]["AVGFEE"]!=null)
					{
						change2 = Number(data.thisPeriodThisYear[0]["AVGFEE"]).toFixed(2)-Number(data.lastPeriodLastYear[0]["AVGFEE"]).toFixed(2);
					}
					var change3 = "";
					if(data.thisPeriodLastYear[0]["AVGFEE"]!=null&&data.lastPeriodLastYear[0]["AVGFEE"]!=null)
					{
						change3 = Number(data.thisPeriodLastYear[0]["AVGFEE"]).toFixed(2)-Number(data.lastPeriodLastYear[0]["AVGFEE"]).toFixed(2);
					}
					var diff1 = "";
					if(""!=change1&&""!=change2&&!isNaN(change1)&&!isNaN(change2))
					{
						diff1 = (change1/change2*100).toFixed(1)+"%";
					}
					var diff2 = "";
					if(data.thisPeriodThisYear[0]["AVGFEE"]!=null&&data.thisPeriodCity[0]["AVGFEE"]!=null)
					{
						diff2 = Number(data.thisPeriodThisYear[0]["AVGFEE"]).toFixed(2)-Number(data.thisPeriodCity[0]["AVGFEE"]).toFixed(2);
					}
					var diff3 = "";
					if(data.lastPeriodLastYear[0]["AVGFEE"]!=null&&data.lastPeriodCity[0]["AVGFEE"]!=null)
					{
						diff3 = Number(data.lastPeriodLastYear[0]["AVGFEE"]).toFixed(2)-Number(data.lastPeriodCity[0]["AVGFEE"]).toFixed(2);
					}
					var avgFee_1 = dealwithFloat(change1);
					if(change1 >= 0){
						$("#"+tabId+" #avgFee_1").html("增加"+avgFee_1);
					}else{
						$("#"+tabId+" #avgFee_1").html("减少"+dealwithFloat(Math.abs(change1)));
					}
					var avgFee_2 = dealwithFloat(change2);
					if(change2 >= 0){
						$("#"+tabId+" #avgFee_2").html("增加"+avgFee_2);
					}else{
						$("#"+tabId+" #avgFee_2").html("减少"+dealwithFloat(Math.abs(change2)));
					}
					
					$("#"+tabId+" #stdyear_1").html(data.year);
					$("#"+tabId+" #year_1").html(year);
					var avgFeeRatioHtml1 = "有100%是合理的";
					var avgFeeRatioHtml2 = "有0%是不合理的";
					if(change1 && change2){
						if(change1>0 && change2>0){
							if(change1>change2){
								diff1 = "100%";
								avgFeeRatioHtml1 = "有100%是合理的";
								avgFeeRatioHtml2 = "有0%是不合理的";
							}else{
								var ratio = (change1/change2*100).toFixed(2);
								diff1 = ratio+"%";
								var ratio1 = (100 - change1/change2*100).toFixed(2);
								avgFeeRatioHtml1 = "有"+ratio+"%是合理上升";
								avgFeeRatioHtml2 = "有"+ratio1+"%是不合理上升";
							}
						}else if(change1<0 && change2<0){
							if(change1>change2){
								diff1 = "100%";
								avgFeeRatioHtml1 = "有100%是合理的";
								avgFeeRatioHtml2 = "有0%是不合理的";
							}else{
								var ratio = (change2/change1*100).toFixed(2);
								diff1 = ratio+"%";
								var ratio1 = (100 - change2/change1*100).toFixed(2);
								avgFeeRatioHtml1 = "有"+ratio+"%是合理的";
								avgFeeRatioHtml2 = "还有"+ratio1+"%下降空间";
							}
						}else if(change1>0 && change2<0){
							diff1 = "100%";
							avgFeeRatioHtml1 = "有100%是合理的";
							avgFeeRatioHtml2 = "有0%是不合理的";
						}else{
							diff1 = "0%";
							avgFeeRatioHtml1 = "有0%是合理的";
							avgFeeRatioHtml2 = "有100%是不合理的";
						}
						$("#"+tabId+" #avgFeeRatio_1").html(avgFeeRatioHtml1);
						$("#"+tabId+" #avgFeeRatio_2").html(avgFeeRatioHtml2);
					} else {
						$("#"+tabId+" #avgFeeRatio_1").html(avgFeeRatioHtml1);
						$("#"+tabId+" #avgFeeRatio_2").html(avgFeeRatioHtml2);
					}
					$('#'+tabId+' #table1').html(''
							+'<tr><td>本期<span id="thisPeriod"></span>理论值</td>'
							+'<td id="this_lastCity">'+dealwithFloatMillion(data.thisPeriodCity[0]["TOTALFEE"])+'</td>'
							+'<td id="this_lastCityAvg">'+dealwithFloat(data.thisPeriodCity[0]["AVGFEE"] )+'</td>'
							+'<td rowspan="2"><a id="avgFee1" href="javascript:showDetailPop(1)">'+dealwithFloat(change1)+'</a></td>'
//							修改+'<td rowspan="4">'+diff1+'</td></tr>' BY RUANSHULI At 2017年3月3日13:37:03
							+'<td rowspan="4">'+diff1+'</td></tr>'
							//
/*							+'<td rowspan="4"><a href="javascript:showDetailPop(4)">'+diff1+'</a></td></tr>'
*/						+'<tr><td>同期<span id="lastPeriod"></span>理论值</td>'
							+'<td id="last_lastCity">'+dealwithFloatMillion(data.lastPeriodCity[0]["TOTALFEE"])+'</td>'
							+'<td id="last_lastCityAvg">'+dealwithFloat(data.lastPeriodCity[0]["AVGFEE"])+'</td></tr>'
						+'<tr><td>本期<span id="thisPeriod"></span>实际值</td>'
							+'<td id="this_thisHosp">'+dealwithFloatMillion(data.thisPeriodThisYear[0]["TOTALFEE"])+'</td>'
							+'<td id="this_thisHospAvg">'+dealwithFloat(data.thisPeriodThisYear[0]["AVGFEE"])+'</td>'
							+'<td id="avgFee2" rowspan="2">'+dealwithFloat(change2)+'</td>'
							+'</tr>'
						+'<tr><td>同期<span id="lastPeriod"></span>实际值</td>'
							+'<td id="hospTotalFee">'+dealwithFloatMillion(data.lastPeriodLastYear[0]["TOTALFEE"])+'</td>'
							+'<td id="hospAvgFee">'+dealwithFloat(data.lastPeriodLastYear[0]["AVGFEE"])+'</td>'
							+'</tr>'
						/*+'<tr><td>本期病例<br>'+(year-1)+'年本院均值</td>' 
							+'<td>'+dealwithInt(data.thisPeriodLastYear[0]["DRGCNT"]) +'</td>'
							+'<td id="this_lastHosp">'+dealwithFloatMillion(data.thisPeriodLastYear[0]["TOTALFEE"])+'</td>'
							+'<td id="this_lastHospNum"><a href="javascript:disGroupAnalysisLoadCaseDtl(\''+depType+'\',\''+depGroupCode+'\',\''+depCode+'\',\''+dateFrom+'\',\''+dateTo+'\',\'thisyear\')">'+dealwithInt(data.thisPeriodLastYear[0]["CASECNT"])+'</a></td>'
							+'<td id="this_lastHospAvg">'+dealwithFloat(data.thisPeriodLastYear[0]["AVGFEE"])+'</td>'
							+'<td rowspan="2"><a href="javascript:showDetailPop("AVGFEE")"'+dealwithFloat(change3)+'</a></td>'
							+'<td></td></tr>'
						+'<tr><td>同期病例<br>'+(year-1)+'年本院均值</td>'
							+'<td>'+dealwithInt(data.lastPeriodLastYear[0]["DRGCNT"]) +'</td>'
							+'<td id="last_lastHosp">'+dealwithFloatMillion(data.lastPeriodLastYear[0]["TOTALFEE"])+'</td>'
							+'<td id="last_lastHospNum"><a href="javascript:disGroupAnalysisLoadCaseDtl(\''+depType+'\',\''+depGroupCode+'\',\''+depCode+'\',\''+dateFrom+'\',\''+dateTo+'\',\'lastyear\')">'+dealwithInt(data.lastPeriodLastYear[0]["CASECNT"]) +'</a></td>'
							+'<td id="last_lastHospAvg">'+dealwithFloat(data.lastPeriodLastYear[0]["AVGFEE"])+'</td><td></td></tr>'*/)
							//本期和同期后面加上相应的监测时间
							$('#'+tabId+' #thisPeriod').html($(".time_id").html());
							$('#'+tabId+' #lastPeriod').html(getTime("year"));
							
						var avgFee_1 = data.lastPeriodCity[0]["AVGFEE"];
						var avgFee_2 = data.lastPeriodLastYear[0]["AVGFEE"];
						
						var color_1 = "red";
						if(avgFee_1>avgFee_2){
							color_1 = "green";
						}
						avgFee_1 = avgFee_1?avgFee_1.toFixed(2):0;//全市同期值
						avgFee_2 = avgFee_2?avgFee_2.toFixed(2):0;//全院同期值
						var avgFee_3 = data.thisPeriodCity[0]["AVGFEE"];
						avgFee_3 = avgFee_3?avgFee_3.toFixed(2):0;//全市本期值
						var avgFee_4 = data.thisPeriodThisYear[0]["AVGFEE"];
						avgFee_4 = avgFee_4?avgFee_4.toFixed(2):0;//全院本期值
						var color_2 = "red";
						if(avgFee_3>avgFee_4){
							color_2 = "green";
						}
						var lineData_1 = [{x:90,yAxis:Number(avgFee_2)},{x:180,yAxis:Number(avgFee_4)}];//全院
						var lineData_2 = [{x:280,yAxis:Number(avgFee_1)},{x:370,yAxis:Number(avgFee_3)}];//全市
						var markLine=[lineData_1,lineData_2];
						var data=[{ddesc:'全院均值',quotaValueCC:avgFee_2,quotaValue:avgFee_4},{ddesc:'全市均值',quotaValueCC:avgFee_1,quotaValue:avgFee_3}];
						var lines = [{"code":'quotaValueCC',"desc":'同期值'+getTime("year"), "data":[]},{"code":'quotaValue',"desc": '本期值'+$(".time_id").html(), "data":[]}];
						var chartParams={isStack:false,legendPosition:'bottom',markLine:markLine};
						//由原来的$("#compareDiv .echartscq")，修改为$("#compareDiv #"+myEchartId)
						barChart($("#compareDiv #"+myEchartId), lines, data, '不同标杆类型下次均费用同比变化', '',chartParams);
//				}
			});
}

function drgsCntLink(number,code,title){
	if (number!=null && "" != number && number>0) {
		title += ' DRG病组详情';
		return '<a href="javascript:showDRGsDetail(\''+code+'\',\''+title+'\');">'+number+'</a>';
	} 
	return "";
}

function overproofDrgsCntLink(number,code,title){
	if (number!=null && "" != number && number>0) {
		title += ' 费用超标的DRG病组详情';
		return '<a href="javascript:showOverproofDRGsDetail(\''+code+'\',\''+title+'\');">'+number+'</a>';
	} 
	return 0;
}

//四舍五入
function dealwithInt(number){
	if (number!=null && "" != number) {
		return formatNumber(number);
	} 
	return "";
}
function dealwithFloat(number){
	if (number!=null&& "" != number) {
		return formatNumber(Number(number).toFixed(2));
	}
	return "";
}
function dealwithFloatMillion(number){
	if (number!=null&& "" != number) {
		return formatNumber(Number(number/10000).toFixed(2));
	}
	return "";
}


//加载病组详情表格
function showDRGsDetail(queryType,title){
	var param = drgUI.setAjaxData(tabId);//获取当前页面 初始参数
	param.tableType = "patientGroup";
	param.title = title;
	param.queryType = queryType;
	param.depGroupCode = $("#"+tabId+" #depGroupList").val();
	param.depCode = $("#"+tabId+" #depList").val();
	param.wardCode = $("#"+tabId+" #wardList").val();
	openTab('/pages/yibao/fenxi/disGroupDetail.jsp', '病组详情',"disGroupAnalysis_disGroupDetail","disGroupAnalysis_disGroupDetail",param);
//	$.post(contextPath + '/pages/common/top-dialog.jsp').done(function(data){
//		var param = drgUI.setAjaxData(tabId);//获取当前页面 初始参数
//		var dateFrom = param.dateFrom;
//		var dateTo = param.dateTo;
//		var thisYear  = dateFrom.substring(0,4) ;
//		var lastYear  = (dateFrom.substring(0,4)-1)+"" ;
//		var dialog  = $(data);
//		dialog.find(".modal-title").html("病组详情");
//		dialog.find(".modal-dialog").css("width","1000px");
//		dialog.find("#echartcq4").css("width","100%");
//		dialog.find(".modal-footer").css("border-top","0px");
//		dialog.modal({
//			keyboard: false
//		}).on({
//			'hidden.bs.modal' : function(){
//				$(this).remove();
//			},
//			'shown.bs.modal' : function(){
//				dialog.find("#echartcq4").html("<table id =\"drgDetail\"  class=\"table\" width=\"100%\" style=\"white-space: nowrap; \"><thead>"+
//						" <tr>"+
//						" <th colspan=\"2\" style=\"text-align:center\">DRG代码及描述</th>"+
//						" <th colspan=\"4\" style=\"text-align:center\"><i class=\"icon-group\" style=\"color: #007dbc;font-size: 14px;\"></i>患者数</th>"+
//						" <th colspan=\"2\" style=\"text-align:center\"><i class=\"glyphicon glyphicon-usd\" style=\"color: #007dbc;font-size: 14px;\"></i>次均费用</th>"+
//						" <th colspan=\"2\" style=\"text-align:center\"><i class=\"fa fa-bed\" style=\"color: #007dbc;font-size: 16px;\"></i>平均住院日</th>"+
//						" <th rowspan=\"2\" style=\"vertical-align:middle\" >权重</th>"+
//						" </tr><tr>"+
//						" <th>代码</th>"+
//						" <th>描述</th>"+
//						" <th>排序</th>"+
//						" <th>"+lastYear+"</th>"+
//						" <th>排序</th>"+
//						" <th>"+thisYear+"</th>"+
//						" <th>"+lastYear+"</th>"+
//						" <th>"+thisYear+"</th>"+
//						" <th>"+lastYear+"</th>"+
//						" <th>"+thisYear+"</th>"+
//						" </tr>"+
//						" </thead></table>");
//				
//				var depGroupCode=$("#"+tabId+" #depGroupList").val();
//				var depCode=$("#"+tabId+" #depList").val();
//				var wardCode=$("#"+tabId+" #wardList").val();
//				param.queryType = queryType;
//				param.depGroupCode = depGroupCode;
//				param.depCode = depCode;
//				param.wardCode = wardCode;
//				$.post(contextPath +"/DisGroupAnalysis/drgsDetail.dhc",param).done(function(result){
//					var data = result.data ;
//					var columns=[
//				                  	{"data": "DRGCODE"},
//				                  	{"data": "DRGDESC"},
//				                  	{"data": "LASTORDER"},
//				                  	{"data": "LPCNT"} ,
//				                  	{"data": "THISORDER"},
//				                  	{"data": "TPCNT"},
//				                  	{"data": "LAVGFEE",
//				                  		"render": function(obj, type, full) {
//				                  			return formatNumber(full["LAVGFEE"],2) ;
//					                     }
//				                  	},
//				                	{"data": "AVGFEE","width":"120px",
//				                  		"render": function(obj, type, full) {
//				                  			return formatNumber(full["AVGFEE"],2) + "" + gridcompareValue(full["AVGFEE"],full["LAVGFEE"]) ;
//					                     }
//				                  	},
//				                	{"data": "LAVGDAY",
//				                  		"render": function(obj, type, full) {
//				                  			return formatNumber(full["LAVGDAY"],2) ;
//					                     }
//				                  	},
//				                	{"data": "AVGDAY","width":"100px",
//				                  		"render": function(obj, type, full) {
//				                  			return formatNumber(full["AVGDAY"],2) + "" + gridcompareValue(full["AVGDAY"],full["LAVGDAY"]) ;
//					                     }
//				                  	},
//				                	{"data": "WEIGHT"} 
//				                 ];
//					var paramsDataTables={searching:true,lengthChange:true,ordering:true,"order": [[ 4, 'asc' ]],stateSave:false,info:false,scrollX:true,scrollY:'280px',autoWidth:false,orderCellsTop:true,tableTitle:"病组明细"};
//					dialog.find("#drgDetail").dataTableBasic(columns,data,paramsDataTables);
//				});
//			}
//		});
//	});
}

//加载费用超标病组详情表格
function showOverproofDRGsDetail(queryType,title){
	var param = drgUI.setAjaxData(tabId);//获取当前页面 初始参数
	param.tableType = "overproofPatientGroup";
	param.title = title;
	param.queryType = queryType;
	param.depGroupCode = $("#"+tabId+" #depGroupList").val();
	param.depCode = $("#"+tabId+" #depList").val();
	param.wardCode = $("#"+tabId+" #wardList").val();
	openTab('/pages/yibao/fenxi/disGroupDetail.jsp', '费用超标病组详情',"disGroupAnalysis_disGroupDetail","disGroupAnalysis_disGroupDetail",param);
//	$.post(contextPath + '/pages/common/top-dialog.jsp').done(function(data){
//		var param = drgUI.setAjaxData(tabId);//获取当前页面 初始参数
//		var depGroupCode=$("#"+tabId+" #depGroupList").val();
//		var depCode=$("#"+tabId+" #depList").val();
//		var wardCode=$("#"+tabId+" #wardList").val();
//		var dateFrom = param.dateFrom;
//		var dateTo = param.dateTo;
//		var thisYear  = dateFrom.substring(0,4) ;
//		var lastYear  = (dateFrom.substring(0,4)-1)+"" ;
//		if(queryType=="last" || queryType=="thisNo"){
//			thisYear = lastYear ;
//		}else{
//			$('#'+tabId+' .thisyear').html(dateFrom.substring(0,4));
//		}
//		var dialog  = $(data);
//		dialog.find(".modal-title").html("费用超标病组详情");
//		dialog.find(".modal-dialog").css("width","1000px");
//		dialog.find("#echartcq4").css("width","100%");
//		dialog.find(".modal-footer").css("border-top","0px");
//		dialog.modal({
//			keyboard: false
//		}).on({
//			'hidden.bs.modal' : function(){
//				$(this).remove();
//			},
//			'shown.bs.modal' : function(){
//				dialog.find("#echartcq4").html("<table id =\"drgDetail\"  class=\"table\" width=\"100%\" style=\"white-space: nowrap; \"><thead>"+
//						" <tr>"+
//						" <th colspan=\"2\" style=\"text-align:center\">DRG代码及描述</th>"+
//						" <th colspan=\"2\" style=\"text-align:center\"><i class=\"icon-group\" style=\"color: #007dbc;font-size: 14px;\"></i>患者数</th>"+
//						" <th colspan=\"2\" style=\"text-align:center\"><i class=\"glyphicon glyphicon-usd\" style=\"color: #007dbc;font-size: 14px;\"></i>次均费用</th>"+
//						" <th colspan=\"2\" style=\"text-align:center\"><i class=\"fa fa-bed\" style=\"color: #007dbc;font-size: 16px;\"></i>平均住院日</th>"+
//						" <th rowspan=\"2\" style=\"vertical-align:middle\">权重</th>"+
//						" </tr><tr>"+
//						" <th>代码</th>"+
//						" <th>描述</th>"+
//						" <th>排序</th>"+
//						" <th>"+thisYear+"</th>"+
//						" <th>"+thisYear+"</th>"+
//						" <th>病组标杆</th>"+
//						" <th>"+thisYear+"</th>"+
//						" <th>病组标杆</th>"+
//						" </tr>"+
//						" </thead></table>");
//				param.queryType = queryType;
//				param.depGroupCode = depGroupCode;
//				param.depCode = depCode;
//				param.wardCode = wardCode;
//				$.post(contextPath +"/DisGroupAnalysis/overproofDrgsDetail.dhc",param).done(function(result){
//					var data = result.data ;
//					var columns=[
//				                  	{"data": "DRGCODE"},
//				                  	{"data": "DRGDESC"},
//				                  	{"data": "",
//					               		"render":function(data,type,full,meta){
//					               			return meta.row+1 ;
//					               		}
//					               	},
//				                  	{"data": "INCASECNT"},
//				                  	{"data": "AVGFEE",
//				                  		"render": function(obj, type, full) {
//				                  			return formatNumber(full["AVGFEE"],2) ;
//					                     }
//				                  	},
//				                	{"data": "AS_AVG_FEE","width":"120px",
//				                  		"render": function(obj, type, full) {
//				                  			return formatNumber(full["AS_AVG_FEE"],2) ;
//					                     }
//				                  	},
//				                	{"data": "AVGDAY",
//				                  		"render": function(obj, type, full) {
//				                  			return formatNumber(full["AVGDAY"],2) ;
//					                     }
//				                  	},
//				                	{"data": "AS_AVG_DAYS","width":"100px",
//				                  		"render": function(obj, type, full) {
//				                  			return formatNumber(full["AS_AVG_DAYS"],2) ;
//					                     }
//				                  	},
//				                	{"data": "WEIGHT"} 
//				                 ];
//					var paramsDataTables={searching:true,lengthChange:true,ordering:true,"order": [[ 3, 'desc' ]],stateSave:false,info:false,scrollX:true,scrollY:'280px',autoWidth:false,orderCellsTop:true,tableTitle:"病组明细"};
//					dialog.find("#drgDetail").dataTableBasic(columns,data,paramsDataTables);
//				})
//			}
//		})
//	})
}

//比较函数，用语比较 FD29-123 这种数
function compareFunc(a,b){
	var numA=a.substring(a.indexOf('-')+1,a.length);
	var numB=b.substring(b.indexOf('-')+1,b.length);
	return numB-numA;
}



//展开日期标杆
function opc1(){
	if ($('#'+tabId+' #date_div').css('position')=='fixed') {
		$('#'+tabId+' #date_div').removeClass("hoverOut").addClass("hoverIn");
	}
}
//收起日期标杆
function opc0(){
	if ($('#'+tabId+' #date_div').css('position')=='fixed') {
		$('#'+tabId+' #date_div').removeClass("hoverIn").addClass("hoverOut");
	}
}

//日期字符串
function GetDateStr(AddDayCount) {
    var dd = new Date();
    dd.setDate(dd.getDate()+AddDayCount);//获取AddDayCount天后的日期
    var y = dd.getFullYear();
    var m = dd.getMonth()+1;//获取当前月份的日期
    if(m<10)
	{m = "0"+m;}
    return y+"-"+m;
}

function showDetailPop(i){
	var desc = "全院" ;
	var depGroup = $("#"+tabId+" #depGroupList option:selected").text() ;
	var dep = $("#"+tabId+" #depList option:selected").text() ;
	var ward = $("#"+tabId+" #wardList option:selected").text() ;
	if(ward!="" && ward!="全部"){
		desc = ward ;
	} else if(dep!="" && dep!="全部"){
		desc = dep ;
	} else if(depGroup!="" && depGroup!="全院"){
		desc = depGroup ;
	}
	var content='';
	switch (i) {
	case 1:
		content = '统计时间段内，'+desc+'DRGs组数为 '+dataCopy.thisPeriodThisYear[0].DRGCNT+' 组，'
			+'入组病例 '+dataCopy.thisPeriodThisYear[0].CASECNT+' 例，'
			+'按照'+$('#table1 #cityYear').text()+'年全市各DRG病组费用均值计算，'
			+'得'+desc+'总费用为 '+$('#table1 #this_lastCity').text()+' 万元，'
			+'次均费用为 '+$('#table1 #this_lastCityAvg').text()+' 元，'
			+'去年同期，'+desc+'DRGs组数为 '+dataCopy.lastPeriodLastYear[0].DRGCNT+' 组，'
			+'入组病例 '+dataCopy.lastPeriodLastYear[0].CASECNT+' 例，'
			+'按照'+$('#table1 #cityYear').text()+'年全市各DRG病组费用均值计算，'
			+'得'+desc+'总费用为 '+$('#table1 #last_lastCity').text()+' 万元，'
			+'次均费用为 '+$('#table1 #last_lastCityAvg').text()+' 元，'
			+'次均费用本期比去年同期相比高 '+($('#table1 #this_lastCityAvg').text().replace(",","")-$('#table1 #last_lastCityAvg').text().replace(",","")).toFixed(2)+' 元。'
		break;
	case 2:
		content = '统计时间段内，'+desc+'DRGs组数为 '+$('#table1 #thisYearDrgNum').text()+' 组，'
			+'入组病例 '+$('#table1 #thisYearNum').text()+' 例，'
			+'按照'+$('#table1 #thisYear').text()+'年本院各DRG病组费用均值计算，'
			+'得'+desc+'总费用为 '+$('#table1 #this_thisHosp').text()+' 万元，'
			+'次均费用为 '+$('#table1 #this_thisHospAvg').text()+' 元，'
			+'去年同期，'+desc+'DRGs组数为 '+$('#table1 #lastYearDrgNum').text()+' 组，'
			+'入组病例 '+$('#table1 #lastYearNum').text()+' 例，'
			+'按照'+$('#table1 #thisYear').text()+'年本院各DRG病组费用均值计算，'
			+'得'+desc+'总费用为 '+$('#table1 #last_lastHosp').text()+' 万元，'
			+'次均费用为 '+$('#table1 #last_lastHospAvg').text()+' 元，'
			+'次均费用本期比去年同期相比高 '+($('#table1 #this_thisHospAvg').text().replace(",","")-$('#table1 #last_lastHospAvg').text().replace(",","")).toFixed(2)+' 元。'
		break;
	case 3:
		content = '统计时间段内，'+desc+'DRGs组数为 '+$('#table1 #thisYearDrgNum').text()+' 组，'
			+'入组病例 '+$('#table1 #thisYearNum').text()+' 例，'
			+'按照'+$('#table1 #lastYear').text()+'年全院各DRG病组费用均值计算，'
			+'得'+desc+'总费用为 '+$('#table1 #this_lastHosp').text()+' 万元，'
			+'次均费用为 '+$('#table1 #this_lastHospAvg').text()+' 元，'
			+'去年同期，'+desc+'DRGs组数为 '+$('#table1 #lastYearDrgNum').text()+' 组，'
			+'入组病例 '+$('#table1 #lastYearNum').text()+' 例，'
			+'按照'+$('#table1 #lastYear').text()+'年全院各DRG病组费用均值计算，'
			+'得'+desc+'总费用为 '+$('#table1 #last_lastHosp').text()+' 万元，'
			+'次均费用为 '+$('#table1 #last_lastHospAvg').text()+' 元，'
			+'次均费用本期比去年同期相比高 '+($('#table1 #this_lastHospAvg').text().replace(",","")-$('#table1 #last_lastHospAvg').text().replace(",","")).toFixed(2)+' 元。'
		break;
	case 4:
		content = '根据全市DRG病组费用标杆计算，本期病例的理论次均费用较去年同期的'
			+'理论次均费用高'+$('#table1 #avgFee1').text()+' 元，'
			+'根据全院DRG病组费用均值计算，本期病例的实际次均费用较去年同期的实际次均费用高'+$('#table1 #avgFee2').text()+' 元。<br>'
			+'即由于'+desc+'内救治病例DRG病组结构的变化，理论上本期次均费用可以比去年同期次均费用高'+$('#table1 #avgFee1').text()+' 元，'
			+'但是实际上，本期次均费用比去年同期高'+$('#table1 #avgFee2').text()+' 元。'
			+'次均费用实际增长量'+$('#table1 #avgFee2').text()+' 元中有'+(Number($('#table1 #avgFee1').text().replace(",",""))/Number($('#table1 #avgFee2').text().replace(",",""))*100).toFixed(2)+'% 属于合理的增长，'
			+'其余的'+(100-Number($('#table1 #avgFee1').text().replace(",",""))/Number($('#table1 #avgFee2').text().replace(",",""))*100).toFixed(2)+'%有待进一步管控降低。'
		break;
	case 5:
		content = '统计时间段内，'+desc+'DRGs组数为 '+$('#table1 #thisYearDrgNum').text()+' 组，'
			+'入组病例 '+$('#table1 #thisYearNum').text()+' 例，'
			+'按照'+$('#table1 #thisYear').text()+'年全院各DRG病组费用均值计算，'
			+'得'+desc+'总费用为 '+$('#table1 #this_thisHosp').text()+' 万元，'
			+'次均费用为 '+$('#table1 #this_thisHospAvg').text()+' 元，'
			+'按照'+$('#table1 #cityYear').text()+'年全市各DRG病组费用均值计算，'
			+'得'+desc+'总费用为 '+$('#table1 #this_lastCity').text()+' 万元，'
			+'次均费用为 '+$('#table1 #this_lastCityAvg').text()+' 元，'
			+'实际次均费用比根据全市'+$('#table1 #cityYear').text()+'年DRG病组标杆计算所得次均费用高 <strong class="up">'
			+($('#table1 #this_thisHospAvg').text().replace(",","")-$('#table1 #this_lastCityAvg').text().replace(",","")).toFixed(2)+'</strong> 元。'
		break;
	case 6:
		content = '统计时间段同期内，'+desc+'DRGs组数为 '+$('#table1 #lastYearDrgNum').text()+' 组，入组病例  '+$('#table1 #lastYearNum').text()+' 例，'
			+'按照全院各DRG病组费用均值计算，得'+desc+'总费用为 '+$('#table1 #hospTotalFee').text()+' 万元，'
			+'次均费用为 '+$('#table1 #hospAvgFee').text()+' 元，按照全市各DRG病组费用均值计算，'
			+'得'+desc+'总费用为 '+$('#table1 #last_lastCity').text()+' 万元，次均费用为 '+$('#table1 #last_lastCityAvg').text()+' 元，'
			+'实际次均费用比根据全市年DRG病组费用标杆计算所得次均费用高 '+(Number($('#table1 #hospAvgFee').text().replace(",",""))-Number($('#table1 #last_lastCityAvg').text().replace(",",""))).toFixed(2)+' 元。';
		break;
	case 7:
		
		break;
	default:
		break;
	}
	drgsAnalysisPop(content);
}

/**
 * 次均费用两年比较表---病例明细---统一调用case.jsp
 * @param depGroupCode
 * @param depCode
 * @param wardCode
 * @param dateFrom
 * @param dateTo
 * @param monitorType
 * @returns
 */
function disGroupAnalysisLoadCaseDtl(depGroupCode,depCode,wardCode,dateFrom,dateTo,monitorType){
	var param = drgUI.setAjaxData(tabId);//获取当前页面 初始参数
	if(monitorType == 'thisyear'){
		dateFrom = dateFrom+'-01';
		var date = new Date(dateTo.split("-")[0],dateTo.split("-")[1],0);
		dateTo = dateTo+"-"+date.getDate();
	}else if(monitorType == 'lastyear'){
		dateFrom = (dateFrom.split("-")[0]-1)+"-"+dateFrom.split("-")[1]+'-01';
		var date = new Date(dateTo.split("-")[0],dateTo.split("-")[1],0);
		dateTo = (dateTo.split("-")[0]-1)+"-"+dateTo.split("-")[1]+"-"+date.getDate();
	}
	param.dateFrom = dateFrom;
	param.dateTo = dateTo;
	
	if(depGroupCode!=null && depGroupCode!="null"){
		param.depGroupCode = depGroupCode;
	}else{
		param.depGroupCode = "";
	}
	if(depCode!=null && depCode!="null"){
		param.depCode = depCode;
	}else{
		param.depCode = "";
	}
	if(wardCode!=null && wardCode!="null"){
		param.wardCode = wardCode;
	}else{
		param.wardCode = "";
	}
	param.caseLinkCode = 'InCaseCnt';
	openTab('/pages/drgscommon/case.jsp', "病组结构分析|病例明细", "disGroupCaseDtl"+monitorType, "disGroupCaseDtl"+monitorType, param);
}

/**
 * 病组结构分析表--病例明细--单独请求
 * @param depGroupCode
 * @param depCode
 * @param wardCode
 * @param dateFrom
 * @param dateTo
 * @param monitorType
 * @returns
 */
function loadCaseStructure(monitorType){
	var param = drgUI.setAjaxData(tabId);
	var depGroupCode=$("#"+tabId+" #depGroupList").val();
	var depCode=$("#"+tabId+" #depList").val();
	var wardCode=$("#"+tabId+" #wardList").val();
	param.depGroupCode = depGroupCode;
	param.depCode = depCode;
	param.wardCode = wardCode;
	param.monitorType = monitorType;
	$.post(contextPath+'/DisGroupAnalysis/loadCase.dhc',param).done(function(result){
		if(depCode){
			depCode = depCode.replace(/,/g, '');
		}
		openTab('/pages/yizheng/fenxi/caselist.jsp', '病例明细',monitorType+depGroupCode+depCode+wardCode+"structurecaselist",monitorType+depGroupCode+depCode+wardCode+"structurecaselist",{param:param, data:result.data});
	});
}

//弹出框
function drgsAnalysisPop(content){
	 $.post(contextPath + '/pages/common/top-dialog.jsp').done(function(data){
			var dialog  = $(data);
			dialog.find(".modal-title").html("费用变化分析");
			dialog.modal({
				keyboard: false
			}).on({
				'hidden.bs.modal' : function(){
					$(this).remove();
				},
				'shown.bs.modal' : function(){
					dialog.find(".echartscq").html(content).css({'width':'auto','height':'auto'})
				}
			});
	 });
}

//科室组点击事件
function depGroupChange(){
	var param = drgUI.setAjaxData(tabId);
	var depGroupCode=$("#"+tabId+" #depGroupList").val();
	if(depGroupCode=='hosp'){
		$('#'+tabId+' #depList').parent().css('display','none');
		$('#'+tabId+' #wardList').parent().css('display','none');
		loadDrgAnalysisTable('null', 'null','null');
		
	}else{
		$('#'+tabId+' #wardList').parent().css('display','block');
		if(roleCode == "科室")
		{
			var depGroupCode=$("#"+tabId+" #depGroupList").val();
		}
		else
		{
			if(commonLayerConfig[0]=="1")
			{//科室组层次 
				$('#'+tabId+' #depList').parent().css('display','none');
				$('#'+tabId+' #wardList').parent().css('display','none');
			}
			else if(commonLayerConfig[1]=="1")
			{//科室层次
				$('#'+tabId+' #wardList').parent().css('display','none');
			}
			if(commonLayerConfig[1]=="1")
			{
				$.getJSON(contextPath+'/Department/findAllDep.dhc',{'parDepGroupCode':depGroupCode},function(deps){
					$('#'+tabId+' #depList').html('');
					$('#'+tabId+' #depList').parent().css('display','block');
					var data = deps.data;
					var optStr = '<option value="" selected="selected">' + "全部"+ '</option>';
					for (var i = 0; i < data.length; i++) {
						if (i == 0) {
							optStr = optStr + '<option value="' + data[i].depCode
									+ '">' + data[i].depName
									+ '</option>';
						} else {
							optStr = optStr + '<option value="' + data[i].depCode
									+ '">' + data[i].depName + '</option>';
						}
					}
					$("#" + tabId + " #depList").append(optStr);
				});
			}
			else if(commonLayerConfig[2]=="1")
			{
				$.post(contextPath + '/YiZhengHome/getWardInPerf.dhc', {
					'dateFrom' : param.dateFrom,
					'dateTo' : param.dateTo,
					'pardepgroupCode' : depGroupCode
				}).done(function(wards) {
					$('#'+tabId+' #wardList').html('');
					$('#'+tabId+' #wardList').parent().css('display','block');
					var data = wards.data;
					var optStr = '<option value="" selected="selected">' + "全部"+ '</option>';
					for (var i = 0; i < data.length; i++) {
						if (i == 0) {
							optStr = optStr + '<option value="' + data[i].WARD_CODE
									+ '" >' + data[i]. WARD_DESC
									+ '</option>';
						} else {
							optStr = optStr + '<option value="' + data[i].WARD_CODE
									+ '">' + data[i]. WARD_DESC + '</option>';
						}
					}
					$("#" + tabId + " #wardList").append(optStr);
				})
			}
		}
		//加载表格
		loadDrgAnalysisTable(depGroupCode, 'null','null');
	
	}
}
//科室点击事件
function depChange(){
	var param = drgUI.setAjaxData(tabId);
	var depCode=$("#"+tabId+" #depList").val();
	if(depCode=='hosp'){
		$('#'+tabId+' #depGroupList').parent().css('display','none');
		$('#'+tabId+' #wardList').parent().css('display','none');
		loadDrgAnalysisTable('null', 'null','null');
	}else if(depCode==''){//切换至请选择的时候，加载科室组
		var depGroupCode=$("#"+tabId+" #depGroupList").val();
		$('#'+tabId+' #wardList').parent().css('display','none');
		loadDrgAnalysisTable(depGroupCode, 'null','null');
	}else{
	if(commonLayerConfig[1]=="1")
	{//科室层次
		$('#'+tabId+' #wardList').parent().css('display','none');
	}
	if(commonLayerConfig[2]=="1" && depCode?depCode.indexOf(","):""==-1)
	{
		$.post(contextPath + '/YiZhengHome/getWardInPerf.dhc', {
			'dateFrom' : param.dateFrom,
			'dateTo' : param.dateTo,
			'pardepCode' : depCode
		}).done(function(wards) {
			$('#'+tabId+' #wardList').html('');
			$('#'+tabId+' #wardList').parent().css('display','block');
			var data = wards.data;
			var optStr= '<option value="" selected="selected">' + "全部"+ '</option>';
			for (var i = 0; i < data.length; i++) {
				if (i == 0) {
					optStr = optStr + '<option value="' + data[i].WARD_CODE
							+ '">' + data[i].WARD_DESC
							+ '</option>';
				} else {
					optStr = optStr + '<option value="' + data[i].WARD_CODE
							+ '">' + data[i].WARD_DESC + '</option>';
				}
			}
			$("#" + tabId + " #wardList").append(optStr);
		})
	}
	//加载表格
	loadDrgAnalysisTable('null', depCode,'null');
	}
}
//病区点击事件
function wardChange(){
	var wardCode=$("#"+tabId+" #wardList").val();
	//加载表格
	if(wardCode=='hosp'){
		$('#'+tabId+' #depGroupList').parent().css('display','none');
		$('#'+tabId+' #depList').parent().css('display','none');
		loadDrgAnalysisTable('null', 'null','null');
		
	}else if(wardCode==''){//切换至请选择时，加载科室
		var depCode=$("#"+tabId+" #depList").val();
		loadDrgAnalysisTable('null', depCode,'null');
	}else{
		var depCode=$("#"+tabId+" #depList").val();
		loadDrgAnalysisTable('null', depCode,wardCode);	
	}
}
